<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('智能问答配置')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-user-aiAnswer">
        <input name="userId" type="hidden" th:value="${user.userId}"/>
        <input name="userId" type="hidden" th:value="${user.deptId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">用户名：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" readonly="true" name="userName" th:value="${user.userName}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">登录名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" readonly="true" name="loginName" th:value="${user.loginName}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" readonly="true" name="deptName" th:value="${user.deptName}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否开启：</label>
            <div class="col-sm-8" style="color: firebrick;">
                <label class="check-box">
                    <input name="isOpen" value="0" type="radio" checked>允许
                </label>
                <label class="check-box">
                    <input name="isOpen" value="1" type="radio">不允许
                </label>
            </div>
        </div>
        <div id="times_config" class="hidden">
            <div class="form-group" id="times_all">
                <label class="col-sm-3 control-label">可用总次数：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="number" step="1" min="0" name="timesAll" id="timesAll">
                </div>
            </div>
            <div class="form-group" id="times_day">
                <label class="col-sm-3 control-label">每天可用次数：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="number" step="1" min="0" name="timesDay" id="timesDay">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">大模型可用总次数：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" step="1" min="0" name="numsBig" id="numsBig">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">

    var isOpen = 0

    $(function () {
        if (isOpen === 0) {
            $("#times_config").removeClass("hidden")
            let timesAll = $("#timesAll").val()
            if (timesAll > 0){
                $("#times_day").addClass("hidden")
            }
        } else {
            $('#times_config').addClass('hidden')
        }
    });

    //事件监听
    $('input').on('ifChecked', function (event) {
        let menuType = $(event.target).val();
        if (menuType === "0") {
            $("#times_config").removeClass("hidden")
        } else {
            $('#times_config').addClass('hidden')
        }
    })

    //选择部门
    $("#timesAll").change(function (e) {
        let timesAll = $('#timesAll').val();
        if (timesAll > 0) {
            $("#times_day").addClass('hidden')
        } else {
            $("#times_day").removeClass('hidden')
        }
    })



    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(ctx + "system/user/resetPwd", $('#form-user-aiAnswer').serialize());
        }
    }
</script>
</body>

</html>
